﻿using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FineAdmin.IRepository;
using FineAdmin.Model;
using Dapper;

namespace FineAdmin.Repository
{
    public class CategoryRepository : BaseRepository<CategoryModel>, ICategoryRepository
    {
        public int CreateLink()
        {
            using (var conn = SqlHelper.SqlConnection())
            {
                string sql = @"update Category set Link_To='/Search?key='+shortname+'&alid='+ Ali_id";
                return conn.Execute(sql);
            }
        }

        public IEnumerable<CategoryModel> GetCategoryList()
        {
            using (var conn = SqlHelper.SqlConnection())
            {
                string sql = @"SELECT  [Id],[Name],[ShortName],[Ali_id] ,[Tags] ,[Pid],[SortCode],[Icon_B] ,[Icon_S] ,[Style_Type] ,[Link_To] ,[ShowWeb]
      ,[ShowPhone],[CreateTime] ,[UpdateTime] ,[CreateUserId] ,[UpdateUserId] FROM [Category] ORDER BY SortCode ASC";
                return conn.Query<CategoryModel>(sql);
            }
        }
    }
}
